package com.share.demo.controller;

import com.share.demo.dao.UserRepository;
import com.share.demo.event.MsgEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * author:caifan
 * date:2019/11/29
 */
@RestController
public class SpringRest {

    @Autowired
    private ApplicationEventPublisher publisher;

    @Autowired
    UserRepository userRepository;

    @RequestMapping("/event")
    public void event() {
        MsgEvent msgEvent = new MsgEvent(this, userRepository);

        publisher.publishEvent(msgEvent);
    }

}
